package com.cskaoyan.shopping.converter;


import com.cskaoyan.shopping.dal.entitys.ItemCat;
import com.cskaoyan.shopping.dal.entitys.Panel;
import com.cskaoyan.shopping.dal.entitys.PanelContent;
import com.cskaoyan.shopping.dal.entitys.PanelContentItem;
import com.cskaoyan.shopping.dto.PanelContentDto;
import com.cskaoyan.shopping.dto.PanelContentItemDto;
import com.cskaoyan.shopping.dto.PanelDto;
import com.cskaoyan.shopping.dto.ProductCateDto;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;

import java.util.List;


@Mapper(componentModel = "spring")
public interface ContentConverter {

    @Mappings({
            @Mapping(source = "id", target = "id"),
            @Mapping(source = "panelId", target = "panelId"),
            @Mapping(source = "type", target = "type"),
            @Mapping(source = "productId", target = "productId"),
            @Mapping(source = "sortOrder", target = "sortOrder"),
            @Mapping(source = "fullUrl", target = "fullUrl"),
            @Mapping(source = "picUrl", target = "picUrl"),
            @Mapping(source = "picUrl2", target = "picUrl2"),
            @Mapping(source = "picUrl3", target = "picUrl3"),
    })
    PanelContentDto panelContent2Dto(PanelContent panelContent);

    @Mappings({
            @Mapping(source = "id", target = "id"),
            @Mapping(source = "panelId", target = "panelId"),
            @Mapping(source = "type", target = "type"),
            @Mapping(source = "productId", target = "productId"),
            @Mapping(source = "sortOrder", target = "sortOrder"),
            @Mapping(source = "fullUrl", target = "fullUrl"),
            @Mapping(source = "picUrl", target = "picUrl"),
            @Mapping(source = "picUrl2", target = "picUrl2"),
            @Mapping(source = "picUrl3", target = "picUrl3")
    })
    PanelContentDto panelContentItem2Dto(PanelContentItem panelContentItem);

    @Mappings({
            @Mapping(source = "id" , target = "id"),
            @Mapping(source = "name" , target = "name"),
            @Mapping(source = "type" , target = "type"),
            @Mapping(source = "sortOrder" , target = "sortOrder"),
            @Mapping(source = "position" , target = "position"),
            @Mapping(source = "limitNum" , target = "limitNum"),
            @Mapping(source = "status" , target = "status"),
            @Mapping(source = "remark" , target = "remark"),
            @Mapping(source = "panelContentItems" , target = "panelContentItems"),
    })
    PanelDto panel2Dto(Panel panel);

    List<PanelContentDto> panelContents2Dto(List<PanelContent> panelContents);

    List<PanelContentItemDto> panelContentItem2Dto(List<PanelContentItem> panelContentItems);


    // 缺少一个方法; 形式上依旧是 list->list


    @Mappings({
            @Mapping(source = "id", target = "id"),
            @Mapping(source = "panelId", target = "panelId"),
            @Mapping(source = "type", target = "type"),
            @Mapping(source = "productId", target = "productId"),
            @Mapping(source = "sortOrder", target = "sortOrder"),
            @Mapping(source = "fullUrl", target = "fullUrl"),
            @Mapping(source = "picUrl", target = "picUrl"),
            @Mapping(source = "picUrl2", target = "picUrl2"),
            @Mapping(source = "picUrl3", target = "picUrl3")
    })
    PanelContentDto  panelContentItem2PanelContentDtoSingle(PanelContentItemDto panelContentItemDto);
    List<PanelContentDto> panelContentItem2PanelContentDto(List<PanelContentItemDto> panelContentItems);


    @Mappings(
            {
                    @Mapping(source = "id", target = "id"),
                    @Mapping(source = "name", target = "name"),
                    @Mapping(source = "parentId", target = "parentId"),
                    @Mapping(source = "isParent", target = "isParent"),
                    @Mapping(source = "icon", target = "iconUrl")
            }
    )
    ProductCateDto ItemCat2ProductCateDto(ItemCat itemCat);
    List<ProductCateDto> ItemCats2ProductCateDtos(List<ItemCat> itemCats);

}
